﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Resources;
using System.Globalization;
using System.Threading;
using EHTWebsite.Code;

public partial class SanPhanDetail : System.Web.UI.Page
{
    public Boolean IsVN = true;
    private String languageCode = "vi-VN";
    private Int32 categoryID = -1;
    private Int32 productID = -1;
    private Int32 pageIndex = 1;
    private Int32 pageSize = 12;
    private Int32 totalRecord = 0;

    private ResourceManager rm = new ResourceManager("Resources.SiteMap", System.Reflection.Assembly.Load("App_GlobalResources"));

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            languageCode = Session[HangSo.LANGUAGE_CODE].ToString();

            if (languageCode == "en-us")
            {
                IsVN = false;
            }

        }
        catch (Exception ex)
        {
        }

        try
        {
            pageIndex = Int32.Parse(Request.QueryString["PageIndex"].ToString());
        }
        catch (Exception ex)
        {
        }

        try
        {
            categoryID = Int32.Parse(Request.QueryString["CategoryID"].ToString());
        }
        catch (Exception ex)
        {
        }

        try
        {
            productID = Int32.Parse(Request.QueryString["ProductID"].ToString());
        }
        catch (Exception ex)
        {
        }

        if (!Page.IsPostBack)
        {

            EHTWebsite.Code.SanPham theSanPham = EHTWebsite.Code.SanPhamProvider.GetSanPhamBySanPhamID(productID);

            if (theSanPham != null)
            {
                this.ltrTieuDe.Text = (IsVN == true) ? theSanPham.TenSanPhamVN : theSanPham.TenSanPhamOther;
                this.ltrNoiDung.Text = (IsVN == true) ? theSanPham.NoiDungVN : theSanPham.NoiDungOther;
            }

            EHTWebsite.Code.DanhMucSanPham theDanhMucSanPham = DanhMucSanPhamProvider.GetDanhMucSanPhamByDanhMucID(theSanPham.DanhMucID);

            if (theDanhMucSanPham == null)
            {
                theDanhMucSanPham = new DanhMucSanPham();
                theDanhMucSanPham.DanhMucID = -1;
                theDanhMucSanPham.TenDanhMucVN = "tat-ca";
            }

           
            LoadLanguage(Thread.CurrentThread.CurrentCulture);
        }
    }

    public void LoadLanguage(CultureInfo ci)
    {
       // this.ltrDanhSachSanPhamOfCategory_Title.Text = rm.GetString("ltrDanhSachSanPhamOfCategory_Title", ci);
    }
}
